package com.focus.xyz.union.pages.frontend.tables;

import com.focus.xyz.core.common.keyword.Action;
import com.focus.xyz.core.pages.BaseTable;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

/**
 * Created by chenmeng on 2016/4/20.
 */
public class ProxyProdTable extends BaseTable {
    @FindBy(xpath = "//table[@class='tab-order']/tbody")
    private WebElement table;

    @FindBy(xpath = "//div[@class='fn-right']/span")
    private WebElement pCount;

    public ProxyProdTable(WebDriver driver,Action action){
        super(action);
        PageFactory.initElements(driver,this);
        super.table = table;
    }

    @Override
    protected By getLinkLocator() throws Exception {
        return By.xpath("td[4]/a");
    }

    @Override
    protected By getLocator(int index) throws Exception {
        return By.xpath("td[" + index + "]");
    }

    public void linkDetail(String key) throws Exception{
        selectRowAndClickLink(table,key,"查看详情");
    }

    public String getProdCount() throws Exception{
        return pCount.getText();
    }

    public String getProdName(String key) throws Exception{
        return getCellText(table,key,1).trim();
    }

}
